<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <!-- <a-col :span="24">
            <a-form-model-item label="单据id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billId">
              <a-input :disabled=formDisabled v-model="model.billId" :max-length="36"  placeholder="请输入单据id"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="12">
            <a-form-model-item label="结算方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fsettletypeid">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fsettletypeiddata" dictCode="erp_finance_kingdee_base_settle_type,fname,fnumber" placeholder="请选择结算方式"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="应付金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpaytotalamountfor">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpaytotalamountfor" placeholder="请输入应付金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="12">
            <a-form-model-item label="表体-付款金额本位币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpayamounte">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpayamounte" placeholder="请输入表体-付款金额本位币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="表体-付款金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpayamountfore">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpayamountfore" placeholder="请输入表体-付款金额" style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
          <a-col :span="12">
            <a-form-model-item label="对方账户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="foppositeccountname">
              <a-input :disabled=formDisabled v-model="model.foppositeccountname" :max-length="36"  placeholder="请输入对方账户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="对方开户行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="foppositebankname">
              <a-input :disabled=formDisabled v-model="model.foppositebankname" :max-length="36"  placeholder="请输入对方开户行"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="对方银行账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="foppositebankaccount">
              <a-input :disabled=formDisabled v-model="model.foppositebankaccount" :max-length="36"  placeholder="请输入对方银行账号"  ></a-input>
            </a-form-model-item>
          </a-col>
          
          <!-- <a-col :span="12">
            <a-form-model-item label="表体-折后金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fsettlepayamountfor">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fsettlepayamountfor" placeholder="请输入表体-折后金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="表体-未核销金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fnotverificateamount">
              <a-input-number :disabled=formDisabled v-model="model.fnotverificateamount"  :min="0" :precision="2" :max-length="36"  placeholder="请输入表体-未核销金额"   style="width: 100%"/>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="12">
            <a-form-model-item label="我方银行账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="faccountid">
              <a-input :disabled=formDisabled v-model="model.faccountiddata" :max-length="36"  placeholder="请输入我方银行账号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fcomment">
              <a-input :disabled=formDisabled v-model="model.fcomment" :max-length="36"  placeholder="请输入备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="付款用途" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpurposeiddata">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fpurposeiddata" dictCode="erp_finance_kingdee_base_payment_purpose,fname,fnumber" placeholder="请选择付款用途" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="费用承担部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fexpensedeptidE">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fexpensedeptidE" dictCode="erp_omc_team_manager,alias_name,kingdee_org_id" placeholder="请选择费用承担部门" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="费用项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fcostiddata">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fcostiddata" dictCode="erp_finance_kingdee_base_expense_item,fname,fnumber" placeholder="请选择费用项目" disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import moment from 'moment'
  import { mapGetters } from 'vuex'
  import {pushIfNotExist, randomNumber, randomUUID} from '@/utils/util'

  export default {
    name: 'ErpFinanceKingdeePaymentDetailForm',
    components: {
      SelectUserByDep,
      SelectTeamInput,
      SelectCompanyInput,
      SelectCustomerInput
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentDetail/add",
          edit: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentDetail/edit",
          queryById: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentDetail/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      ...mapGetters(['userInfo']),
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            //如果没有id就生成一个uuid
            if (!this.model.id){
              this.model.id = randomUUID();
              // console.log('生成的UUID为：',this.model.id)
            }
            that.$emit('ok', this.model);
          }
        })
      },
    }
  }
</script>
